<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="com.meila.cms.util.page.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String query= "null".equals(request.getParameter("query"))||null==request.getParameter("query")?
      "":request.getParameter("query");
  
  query=query.replaceAll("(pager.offset=[0-9&]*)", "");
  
  if(!"".equals(query)){
     query="&"+query;
  }
 
%>

<pg:pager export="curPage=pageNumber" 
	items="${param.totalRecord}" 
	maxPageItems="<%=SystemContext.getPageSize() %>"
	url="${param.url}">

		<c:forEach items="${param.params}" var="p">
			<pg:param name="${p}"/>
		</c:forEach>
		
    <div class="clearfix" id="sample-table-2_paginate">
	
		<ul class="pagination" style="display: block;">
 
			<pg:first>
				<li>
					<a href="${pageUrl }<%=query %>">首页</a>
				</li>
			</pg:first>
<%-- 			<pg:prev>
				<li>
					<a href="${pageUrl }<%=query %>">上一页</a>
				</li>
			</pg:prev> --%>
			<pg:pages>
				<c:if test="${curPage eq pageNumber }">
					<li class="active"><a>${pageNumber }</a></li>
				</c:if>
				<c:if test="${curPage != pageNumber }">
					<li><a href="${pageUrl }<%=query %>">${pageNumber }</a></li>
				</c:if>
			</pg:pages>
<%-- 			<pg:next>
				<li>
					<a href="${pageUrl }<%=query %>">下一页</a>
				</li>
			</pg:next> --%>
			<pg:last>
				<li>
					<a href="${pageUrl}<%=query %>">尾页</a>
				</li>
			    <script type="text/javascript" >
					 $(document).ready(function(){
					      
					       var  offset=Number(getUrlParamVal('pager.offset'))+2;
                           var  totalRecord  = Number('${param.totalRecord}');
                           
                           if(offset - totalRecord >1){
                               var url = '${param.url}';
                               url=url+"?pager.offset="+(totalRecord-(totalRecord%2==0? 2:1));
                               window.location.href=url;
                           }

					 });
 
					 function topage(){
					 
				        var number = Number($("#number").val());
				        if(number>0  && number <= Number('${pageNumber}')){
				        
				        	    var offset= ($('#number').val()-1)*<%=SystemContext.getPageSize() %>;
						        var url = '${param.url}';
						        url=url+"?pager.offset="+offset;
						        if('${param.query!=null}'=='true'){
						        
						           url=url+'&${param.query}';
						        }
						         window.location.href=url;
				        }
				 
				     }
				     function keyPress() {    
					     var keyCode = event.keyCode;    
					     if ((keyCode >= 48 && keyCode <= 57)) {    
					         event.returnValue = true;    
					     } else {    
					         event.returnValue = false;    
					     }    
					 }  
                </script>
			</pg:last>
 
		</ul>
 
		 <div class="clearfix" style="float:right;margin-top: 5px">
			<pg:last><span>共<font color="red"> ${pageNumber}</font> 页,每页<font color="red"><%=SystemContext.getPageSize() %></font>条,<font color="red">${param.totalRecord }</font>条记录,</span> 到第 <input type="number" id="number" onpaste="return false;"  onkeypress="keyPress()"  max="${pageNumber}" min="1" value="${curPage}" class="console-countInput"/> 页</pg:last>
			<pg:last><span class="label label-primary" onclick="topage()">确定</span></pg:last>
		</div>
		
	  </pg:pager>
	</div>
 		


